function toLogin(data){
	console.log("toLogin",data);
	if(data.code ==202 && (
		data.message == '未登录' ||
		data.message == 'token无效' ||
		data.message === 'token过期')){
		location.href=data.data;
	}
}
async function fetchDataGet(url) {
  try {
    // 发起GET请求
    const response = await axios.get(url);
    toLogin(response.data);
    // 返回请求结果
    //return response.data;
	return Promise.resolve(response.data);
  } catch (error) {
    console.error('Error fetching data:', error);
    throw error;
  }
}

async function fetchDataPostList(url,t,metaInfo) {
  try {
    // 发起GET请求
	var param = {
		"t":t,
		"metaInfo":metaInfo
	}
    const response = await axios.post(url,param);
    //console.log("function",response)
    // 返回请求结果
    //return response.data;
	toLogin(response.data);
	return Promise.resolve(response.data);
  } catch (error) {
    console.error('Error fetching data:', error);
    throw error;
  }
}


async function fetchDataPost(url,param) {
  try {
    // 发起GET请求
    const response = await axios.post(url,param);
    //console.log("function",response)
    // 返回请求结果
    //return response.data;
	toLogin(response.data);
	return Promise.resolve(response.data);
  } catch (error) {
    console.error('Error fetching data:', error);
    throw error;
  }
}


